<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
//String uri = (String)session.getAttribute("uri");

String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<!DOCTYPE HTML>
<html>
  <head>
    
    <title>销售报表 </title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    	
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" type="text/css" href="<%=basePath %>/css/manual.css">
	
  </head>
  
  <body>
  
  <table  width="100%"  border="0" cellpadding="0" cellspacing="0" height="100%">
  	<tr valign="top">
  	
  		<td height="100">
  			 <jsp:include page="/background/operator/head.jsp"></jsp:include>
  		</td>
  	</tr>
  	<tr valign="top">
  		<td>
  		
   
   
  <table width="100%"  border="0" cellpadding="0" cellspacing="0">
  
 <tr>
    	<td width="270" align="center">
    		
    	</td>
    	<td width="100%">

    	</td>
    </tr>
    
    <tr>
    	<td valign="top">
     		<div>
     		
     		</div>
					<s:include value="/background/operator/left.jsp"></s:include>		
     	</td>
     	
     	
     	<td valign="top" >
     	
     	<table width="100%" border="0" cellpadding="0" bgcolor="#e5f3ff" cellspacing="0" style= "border:1px solid #ffffff; border-top-color:#6cb1f1;">
     		<tr>
     			<td>查找销售信息
				<input type="button" value="查看谁有权限" 
     				onclick="javascript:openUrlForDialog('selectoperatorlimitedAction_background.action?limitedCode=<s:property value="limitedCode"/>')"/>
     			</td>
     			
     			<td align="right"> </td>
     		</tr>
     	</table>
     	
     	<table align="center">
     		<tr>
     			<td><s:fielderror id="errormessage" /></td>
     		</tr>
     	</table>
     	<%
						String url = "salesreport.action";//*/
						

						int pageSize = (Integer) request.getAttribute("pageSize");
						int beginPageNum =  (Integer) request.getAttribute("beginPageNum");
						int countRow =  (Integer) request.getAttribute("rowNum");
						int day = (Integer) request.getAttribute("day");
					    int countPage =(countRow-1)/pageSize+1;
					    int currentPage = countPage - (countRow-beginPageNum)/pageSize;
					    String order = (String)request.getAttribute("order");//*/
					    String sort = (String)request.getAttribute("sort");//*/
					    
					   
					    
					    String searchstr = (String)request.getParameter("searchStr");//*/
					    if(searchstr != null){
					    	searchstr = java.net.URLDecoder.decode(searchstr, "UTF-8");
					    	searchstr = java.net.URLEncoder.encode(searchstr,"UTF-8");
					    	searchstr = searchstr.replaceAll("%", "%25");
					    }else{
					    	searchstr = "";
					    }
					    
					    String UrlParameters = "searchStr="+searchstr+"&beginPageNum="+(beginPageNum-pageSize)+"&day="+day+"&order="+order+"&sort="+sort;
					    %>
    <form id="managereceipt_warehouse" name="managereceipt_warehouse" onSubmit="return true;" action="salesreport.action" method="POST" >
    	
			<table  border="0" >
				<tr>
				  <td>
					  查找销售信息:<input type="text" name="searchStr" size="30" value="<s:property value="searchStr"/>"/>
					 日期:<input type="text" name="day" size="30" value="<s:property value="day"/>"/>
					  <input type="submit" value="查找" />
				  </td>
			  </tr>
			</table>
	</form> 
	
	
		<table width="100%" border="0" cellpadding="0" bgcolor="#e5f3ff" cellspacing="0" style= "border:1px solid #ffffff; border-top-color:#6cb1f1;">
     		<tr>
     			<td>销售列表</td>
     		</tr>
     	</table>
		
		
		
		<table border="0" cellpadding="0"  cellspacing="0">
			<tr>
				
					<td style="border-bottom:#e5f3ff solid 1px;" width="105">产品单号</td>
					<td style="border-bottom:#e5f3ff solid 1px;" width="300">产品名称</td>
					<td style="border-bottom:#e5f3ff solid 1px;" width="65">
					
					<s:if test="order =='goodssalesnumber' && sort=='DESC'">
						<a href="salesreport.action?order=goodssalesnumber&sort=ASC&searchStr=<%=searchstr %>&day=<%=day %>">累计</a>
					</s:if>
					<s:else>
						<a href="salesreport.action?order=goodssalesnumber&sort=DESC&searchStr=<%=searchstr %>&day=<%=day %>">累计</a>
					</s:else>
					
					</td>
					<td style="border-bottom:#e5f3ff solid 1px;" width="75" >
					
					<s:if test="order =='number_goods' && sort=='DESC'">
						<a href="salesreport.action?order=number_goods&sort=ASC&<%=searchstr %>&day=<%=day %>">现在库存</a>
					</s:if>
					<s:else>
						<a href="salesreport.action?order=number_goods&sort=DESC&searchStr=<%=searchstr %>&day=<%=day %>">现在库存</a>
					</s:else>
					
					</td>
					<td style="border-bottom:#e5f3ff solid 1px;" width="115" >
					
					<s:if test="order =='goodssalesnumber' && sort=='DESC'">
						<a href="salesreport.action?order=goodssalesnumber&sort=ASC&searchStr=<%=searchstr %>&day=<%=day %>">平均天出售</a>
					</s:if>
					<s:else>
						<a href="salesreport.action?order=goodssalesnumber&sort=DESC&searchStr=<%=searchstr %>&day=<%=day %>">平均天出售</a>
					</s:else>
					
					</td>
					
					<td style="border-bottom:#e5f3ff solid 1px;">
					
					<s:if test="order =='surplusday' && sort=='DESC'">
						<a href="salesreport.action?order=surplusday&sort=ASC&searchStr=<%=searchstr %>&day=<%=day %>">估计缺货时间(天)</a>
					</s:if>
					<s:else>
						<a href="salesreport.action?order=surplusday&sort=DESC&searchStr=<%=searchstr %>&day=<%=day %>">估计缺货时间(天)</a>
					</s:else>

					</td>
					
					<td style="border-bottom:#e5f3ff solid 1px;" width="75">
					<s:if test="order =='profit' && sort=='DESC'">
						<a href="salesreport.action?order=profit&sort=ASC&searchStr=<%=searchstr %>&day=<%=day %>">价值</a>
					</s:if>
					<s:else>
						<a href="salesreport.action?order=profit&sort=DESC&searchStr=<%=searchstr %>&day=<%=day %>">价值</a>
					</s:else>
					
					<td style="border-bottom:#e5f3ff solid 1px;" width="105">
					<s:if test="order =='sumprofit' && sort=='DESC'">
						<a href="salesreport.action?order=sumprofit&sort=ASC&searchStr=<%=searchstr %>&day=<%=day %>">总值(<%=day %>天)</a>
					</s:if>
					<s:else>
						<a href="salesreport.action?order=sumprofit&sort=DESC&searchStr=<%=searchstr %>&day=<%=day %>">总值(<%=day %>天)</a>
					</s:else>
					
					</td>
					
				</tr>
		
			<s:iterator id="receiptList" value="receiptList">
				<tr>	
					<td style="border-bottom:#e5f3ff solid 1px;">
					<a href="#">
						<s:property value="#receiptList.goodsid_receipt"/>
						
					</a>
					</td>
					
					
					<td style="border-bottom:#e5f3ff solid 1px;">
					<a href="#">
						<s:property value="#receiptList.goodsname_receipt"/>
					</a>
					</td>
					<td style="border-bottom:#e5f3ff solid 1px;">
					 
						<s:property value="#receiptList.goodssalesnumber"/>
					
						</td>
					<td style="border-bottom:#e5f3ff solid 1px;">
					<s:property value="#receiptList.goodsnumber"/>
					
					</td>
					<td style="border-bottom:#e5f3ff solid 1px;">
					<s:property value="#receiptList.average"/>
					</td>
					
					<td style="border-bottom:#e5f3ff solid 1px;">
					<s:if test="#receiptList.number_receipt <= 0">
						<font color="#c0c0c0">
						<s:property value="#receiptList.surplusday"/>
						</font>
					</s:if>
					<s:else>
					<font color="blue">
						<s:property value="#receiptList.surplusday"/>
						</font>
					</s:else>
					
					</td>
					
					
					
					<td style="border-bottom:#e5f3ff solid 1px;">
					<font color="red"><s:property value="#receiptList.profit"/></font>
					</td>
					<td style="border-bottom:#e5f3ff solid 1px;">
					<font color="red"><s:property value="#receiptList.sumprofit"/></font>
					</td>
					
						
					
				</tr>
			</s:iterator>
		</table>
	
	<table width="100%" border="0" cellpadding="0" bgcolor="" cellspacing="0" >
				<tr >
					<td >
						
					    <%
					    
					    if((beginPageNum-pageSize+1) >= 1){%>
				    	<a href="<%=url %>?searchStr=<%=searchstr %>&beginPageNum=<%=(beginPageNum-pageSize) %>&day=<%=day %>&order=<%=order %>&sort=<%=sort %>">
								上一页 </a>
				 	  <% }
					    
					    //beginPageNum =  (pageNum - 1) * pageSize;
						StringBuffer chagePageBuff = new StringBuffer();
						if(countPage >= 2){ 
							int begin = currentPage - 9;
							int end = currentPage + 9;
							
							if(begin < 1){
								begin = 0;
							}
							if(end > countPage){
								end = countPage-1;
							}
							
							
							for(int i=begin;i<countPage;i++){
								
								
								
								
								
								if(beginPageNum == i*pageSize){
									%>
									<%=i+1 %>
									<%
								}else{
									%>
									<a href="<%=url %>?searchStr=<%=searchstr %>&beginPageNum=<%=i*pageSize %>&day=<%=day %>&order=<%=order %>&sort=<%=sort %>">
									[<%=i+1 %>] </a>
									<%
								}
								
								if(i > end){
									
									break;
									
								}
							}
						}
						
						if((beginPageNum+pageSize-countRow) < 0){%>
				    	<a href="<%=url %>?searchStr=<%=searchstr %>&beginPageNum=<%=(beginPageNum+pageSize) %>&day=<%=day %>&order=<%=order %>&sort=<%=sort %>">
								下一页 </a>
				   		<% }
						if(countPage != 1){%>
			    		<input type="text" size="4" id="goPageNum" name="goPageNum"/> / <%=countPage %> <button onclick="gotoPage();">跳转</button>
				   		<% }
						//*/
						%>
					</td>

				</tr>
				
			</table>
			
	</td>
	
	
	
</tr>

</table>

</td>
</tr>
<tr valign="bottom">
	<td>
		<jsp:include page="/background/operator/tail.jsp"></jsp:include>
	</td>
</tr>
</table>



  </body>
<script type="text/javascript">


function gotoPage(){
	countPage = <%=countPage %>;
	pageSize = <%=pageSize %>;
	pageNum = document.getElementById("goPageNum").value;

	pageNum = parseInt(pageNum);
	if(pageNum > countPage){
		pageNum = countPage;
	}
	beginPageNum = pageNum * pageSize - pageSize;
	if(beginPageNum < 0){
		beginPageNum = 0;

	}
	if(isNaN(beginPageNum)){
		beginPageNum = 0;
	}
	url = '<%=url %>?searchStr=<%=searchstr %>&day=<%=day %>&order=<%=order %>&sort=<%=sort %>&beginPageNum=' + beginPageNum;
	//alert(url);
	window.location.href=url;
}

</script>
</html>
